package finassist.controller;

import java.util.List;
import finassist.model.User;
import finassist.DAO.LoginUserManagerDAO;
/**
 * AJ Projects
 * LoginUserManager.java
 * Purpose: Login User Database.
 *
 * @author Karthick Natarajan
 * @version 1.0 9/10/13
 */

public class LoginUserManager {

	public int check(User user) {
		
		
		LoginUserManagerDAO logObj = new LoginUserManagerDAO();
		List<User> users = null;
		User user1 = null;
		int result = 0;
		try {
			
			users = logObj.getUserDetails(user);
			if(users.size()!=0)
			{
				user1 = users.get(0);
			}
			
			if(users.size()==0)
			{}
			else if(user1.getUsername().equalsIgnoreCase(user.getUsername()) && user1.getPassword().equalsIgnoreCase(user.getPassword()))
				result = 1;
			else
				result = 0;
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	
}
